﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Matrix
{
    public partial class Form1 : Form
    {
        protected Bitmap bitmap;
        protected Graphics g;

        public Form1()
        {
            InitializeComponent();
            bitmap = new Bitmap(@"D:\My Documents\My Pictures\女仆\002.jpg");
            pictureBox1.Image = bitmap;
            g = pictureBox2.CreateGraphics();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            float x, y, x1, y1, x2, y2, r;
            x = float.Parse(textBox1.Text);
            y = float.Parse(textBox2.Text);
            x1 = float.Parse(textBox3.Text);
            y1 = float.Parse(textBox4.Text);
            x2 = float.Parse(textBox5.Text);
            y2 = float.Parse(textBox6.Text);
            r = float.Parse(textBox7.Text);

            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            //投射
            if (checkBox1.Checked)
            {
                matrix.Shear(x, y);
            }
            //缩放
            if (checkBox2.Checked)
            {
                matrix.Scale(x1, y1);
            }
            //平移
            if (checkBox3.Checked)
            {
                matrix.Translate(x2, y2);
            }
            //旋转
            if (checkBox4.Checked)
            {
                matrix.Rotate(r);
            }
            //对绘图平面实施坐标变换、、
            g.Transform = matrix;
            g.Clear(Color.White);
            g.DrawImage(bitmap,new Point(0,0));
            g.ResetTransform();
        }
    }
}
